{% extends 'AdminBundle:base:index.html.twig' %}
    {% block title %}编辑 用户{% endblock %}
    {% block description %}编辑 用户.{% endblock %}

    {% block head %}{{ parent() }}{% endblock %}

    {% block breadcrumbs %}
        {% embed "AdminBundle:base:breadcrumbs.html.twig" %}
            {% block breadcrumb %}
                <li><a href="#">用户认证</a></li>
                <li><a href="{{ path('authuser_index') }}">用户</a></li>
                <li><a href="{{ path('authuser_new') }}">新建</a></li>
                <li class="active">编辑</li>
                <li><a href="{{ path('authuser_show', { 'id': dataSource.id }) }}">查看</a></li>

            {% endblock %}
        {% endembed %}
    {% endblock %}


    {% block content %}
        <div class="page-header">
            {{ form_start(delete_form) }}
            <input type="submit" value="删除">
            {{ form_end(delete_form) }}
        </div>

        {{ form_start(form) }}

        <div class="form-group">
            {{ form_label(form.username) }}

            <div class="col-sm-9">
                {{ form_widget(form.username) }}
                <span class="help-inline col-xs-12 col-sm-7">
                            <span class="middle">{{ form_errors(form.username) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.email) }}

            <div class="col-sm-9">
                {{ form_widget(form.email) }}
                <span class="help-inline col-xs-12 col-sm-7">
                            <span class="middle">{{ form_errors(form.email) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.password) }}

            <div class="col-sm-9">
                {{ form_widget(form.password) }}
                <span class="help-inline col-xs-12 col-sm-7">
                            <span class="middle">{{ form_errors(form.password) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-top" for="duallist"> 分配 </label>

            <div class="col-sm-8">
                <select multiple="multiple" size="10" name="auth_user[group][]"
                        id="duallist">
                    {% for authGroup in authGroups %}
                        <option value="{{ authGroup.id }}" {{ authGroup.selected }}>{{ authGroup.name }}</option>
                    {% else %}
                        <option value="0">没有可分配</option>
                    {% endfor %}
                </select>

                <div class="hr hr-16 hr-dotted"></div>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.note) }}

            <div class="col-sm-9">
                {{ form_widget(form.note) }}
                <span class="help-inline col-xs-12 col-sm-7">
                            <span class="middle">{{ form_errors(form.note) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.isSuperuser) }}
            <div class="col-sm-9">
                {{ form_widget(form.isSuperuser) }}
                <span class="lbl"></span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.isEnabled) }}
            <div class="col-sm-9">
                {{ form_widget(form.isEnabled) }}
                <span class="lbl"></span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="clearfix form-actions">
            <div class="col-md-offset-3 col-md-9">
                <button class="btn btn-info" type="submit">
                    <i class="ace-icon fa fa-check bigger-110"></i>
                    Submit
                </button>
                &nbsp; &nbsp; &nbsp;
                <button class="btn" type="reset">
                    <i class="ace-icon fa fa-undo bigger-110"></i>
                    Reset
                </button>
            </div>
        </div>

        {{ form_end(form) }}

    {% endblock %}

    {% block css %}
        <link rel="stylesheet" href="/admin/assets/css/bootstrap-duallistbox.min.css"/>
    {% endblock %}
    {% block plugin_scripts %}
        <script src="/admin/assets/js/jquery.bootstrap-duallistbox.min.js"></script>
    {% endblock %}

    {% block javascripts %}

        <!-- inline scripts related to this page -->
        <script type="text/javascript">
            jQuery(function ($) {
                var selectId = 'auth_user[group][]';
                var selector = 'select[name="' + selectId + '"]';
                var permission = $(selector).bootstrapDualListbox(
                        {
                            infoTextFiltered: '<span class="label label-purple label-lg">Filtered</span>',
                            infoText: '组 {0}',
                            infoTextEmpty: '列表为空'
                        });
                var container1 = permission.bootstrapDualListbox('getContainer');
                container1.find('.btn').addClass('btn-white btn-info btn-bold');


                //in ajax mode, remove remaining elements before leaving page
                $(document).one('ajaxloadstart.page', function (e) {
                    $('[class*=select2]').remove();
                    $(selector).bootstrapDualListbox('destroy');
                });

            });

        </script>

    {% endblock %}
